/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Lomanda
 */
@Entity
@Table(name = "tbhistoricostock")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HistoricoStock.findAll", query = "SELECT h FROM HistoricoStock h"),
    @NamedQuery(name = "HistoricoStock.findById", query = "SELECT h FROM HistoricoStock h WHERE h.id = :id"),
    @NamedQuery(name = "HistoricoStock.findByQuantidade", query = "SELECT h FROM HistoricoStock h WHERE h.quantidade = :quantidade"),
    @NamedQuery(name = "HistoricoStock.findByDataOperacao", query = "SELECT h FROM HistoricoStock h WHERE h.dataOperacao = :dataOperacao"),
    @NamedQuery(name = "HistoricoStock.findByDataSistema", query = "SELECT h FROM HistoricoStock h WHERE h.dataSistema = :dataSistema"),
    @NamedQuery(name = "HistoricoStock.findByOperacao", query = "SELECT h FROM HistoricoStock h WHERE h.operacao = :operacao"),
    @NamedQuery(name = "HistoricoStock.findByDetalhes", query = "SELECT h FROM HistoricoStock h WHERE h.detalhes = :detalhes"),
    @NamedQuery(name = "HistoricoStock.findByFkLogin", query = "SELECT h FROM HistoricoStock h WHERE h.fkLogin = :fkLogin")})
public class HistoricoStock implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantidade")
    private double quantidade;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataOperacao")
    @Temporal(TemporalType.DATE)
    private Date dataOperacao;
    @Column(name = "dataSistema")
    @Temporal(TemporalType.DATE)
    private Date dataSistema;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "operacao")
    private String operacao;
    @Size(max = 45)
    @Column(name = "detalhes")
    private String detalhes;
    @Size(max = 45)
    @Column(name = "fkLogin")
    private String fkLogin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkHistorico")
    private List<RequisicaoStock> requisicaoStockList;
    @JoinColumn(name = "fkStock", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private StockStock fkStock;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkHistorico")
    private List<EncomendaStock> encomendaStockList;

    public HistoricoStock() {
    }

    public HistoricoStock(Integer id) {
        this.id = id;
    }

    public HistoricoStock(Integer id, double quantidade, Date dataOperacao, String operacao) {
        this.id = id;
        this.quantidade = quantidade;
        this.dataOperacao = dataOperacao;
        this.operacao = operacao;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getQuantidade() {
        return quantidade;
    }

    public void setQuantidade(double quantidade) {
        this.quantidade = quantidade;
    }

    public Date getDataOperacao() {
        return dataOperacao;
    }

    public void setDataOperacao(Date dataOperacao) {
        this.dataOperacao = dataOperacao;
    }

    public Date getDataSistema() {
        return dataSistema;
    }

    public void setDataSistema(Date dataSistema) {
        this.dataSistema = dataSistema;
    }

    public String getOperacao() {
        return operacao;
    }

    public void setOperacao(String operacao) {
        this.operacao = operacao;
    }

    public String getDetalhes() {
        return detalhes;
    }

    public void setDetalhes(String detalhes) {
        this.detalhes = detalhes;
    }

    public String getFkLogin() {
        return fkLogin;
    }

    public void setFkLogin(String fkLogin) {
        this.fkLogin = fkLogin;
    }

    @XmlTransient
    public List<RequisicaoStock> getRequisicaoStockList() {
        return requisicaoStockList;
    }

    public void setRequisicaoStockList(List<RequisicaoStock> requisicaoStockList) {
        this.requisicaoStockList = requisicaoStockList;
    }

    public StockStock getFkStock() {
        return fkStock;
    }

    public void setFkStock(StockStock fkStock) {
        this.fkStock = fkStock;
    }

    @XmlTransient
    public List<EncomendaStock> getEncomendaStockList() {
        return encomendaStockList;
    }

    public void setEncomendaStockList(List<EncomendaStock> encomendaStockList) {
        this.encomendaStockList = encomendaStockList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistoricoStock)) {
            return false;
        }
        HistoricoStock other = (HistoricoStock) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidade.HistoricoStock[ id=" + id + " ]";
    }
    
}
